﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoadTeam.Model;
using System.Data;
using RoadTeam.Enums;
using RoadTeam.SysInterface;

namespace RoadTeam.BLL
{
    public class CsMaintenanceBLL:BllBase
    {

        public DataTable GetEmptyTable()
        {
            SqlWhere where = new SqlWhere();
            where.Info = new CsMaintenance() { MaintenanceIdentities = "-1" };
            return CsMaintenance.Select(where, GlobalConfig.ConnectionString);
        }

        public bool Insert(DataTable dt, String Json)
        {
             //base.InserLog(Json);
            base.InsertLog(Json, @"RoadTeam.BLL.CsMaintenanceBLL", @"Insert");
            //插入对接系统的维修单
           DataTable dt_Maintenance= FactoryClass.CreateCsMaintenance().GetEmptyTable();
           DataRow dr_Maintenance;
           foreach (DataRow dr in dt.Rows)
           {
               //SubCode,CreateDate,ServType,Content,Linkman,LinkTel,UnitFullName,
               //StaffName,Remark,App_Identities
               dr_Maintenance=dt_Maintenance.NewRow();
               dr_Maintenance[0]=dr["MaintenanceCode"];
               dr_Maintenance[1]=dr["MaintenanceDate"];
               dr_Maintenance[2]=dr["MaintenanceType"];
               dr_Maintenance[3]=dr["MaintenanceContent"];
               dr_Maintenance[4]=dr["MaintenanceContact"];
               dr_Maintenance[5]=dr["MaintenanceContactPhone"];
               dr_Maintenance[6]=dr["MaintenanceAddress"];
               dr_Maintenance[7]=dr["MaintenanceCreater"];
                dr_Maintenance[8]=dr["MaintenanceRemark"];
                dr_Maintenance[9] = dr["MaintenanceIdentities"];
               dt_Maintenance.Rows.Add(dr_Maintenance);
           }
            FactoryClass.CreateCsMaintenance().InsertCsMaintenance(dt_Maintenance);
            CsMaintenance.InsertDatatable(dt, GlobalConfig.ConnectionString);
            return false;
        }



    }
}
